#include "StdAfx.h"
#include "Cube.h"

CCube::CCube(void)
{
}

CCube::CCube(CPoint3D pBegin, CPoint3D pEnd)
{
	m_Begin = pBegin;
	m_End = pEnd;
}

void CCube::Draw()
{
	float x, y, r, z, width, height;

	x = (m_Begin.getX() + m_End.getX())/2;
	y = (m_Begin.getY() + m_End.getY())/2;
	z = (m_Begin.getZ() + m_End.getZ())/2;
	width=abs(m_Begin.getX() - m_End.getX());
	height=abs(m_Begin.getY() - m_End.getY());
	r = min(width, height);

	glPushMatrix();
	glTranslatef(x, y, z);
	glRotatef(rotateX, 1.0, 0.0, 0.0);
	glRotatef(rotateY, 0.0, 1.0, 0.0);
	glRotatef(rotateZ, 0.0, 0.0, 1.0);

	if (selected == true)
	{
		glMaterialfv(GL_FRONT, GL_AMBIENT, blue);
	}
	else 
	{
		glMaterialfv(GL_FRONT, GL_AMBIENT, black);
	}
	glutSolidCube(r);

	glPopMatrix();
}
CCube::~CCube(void)
{
}
